home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / test_wave.py < prev    next >
Text File  |  2005-11-19  |  722b  |  33 lines

  1. from test.test_support import TestFailed, TESTFN
  2. import os
  3. import wave
  4.  
  5. def check(t, msg=None):
  6.     if not t:
  7.         raise TestFailed, msg
  8.  
  9. nchannels = 2
  10. sampwidth = 2
  11. framerate = 8000
  12. nframes = 100
  13.  
  14. f = wave.open(TESTFN, 'wb')
  15. f.setnchannels(nchannels)
  16. f.setsampwidth(sampwidth)
  17. f.setframerate(framerate)
  18. f.setnframes(nframes)
  19. output = '\0' * nframes * nchannels * sampwidth
  20. f.writeframes(output)
  21. f.close()
  22.  
  23. f = wave.open(TESTFN, 'rb')
  24. check(nchannels == f.getnchannels(), "nchannels")
  25. check(sampwidth == f.getsampwidth(), "sampwidth")
  26. check(framerate == f.getframerate(), "framerate")
  27. check(nframes == f.getnframes(), "nframes")
  28. input = f.readframes(nframes)
  29. check(input == output, "data")
  30. f.close()
  31.  
  32. os.remove(TESTFN)
  33.